<template>
	<view class="good-item">
		<!-- left -->
		<view class="good-item-left">
			<radio v-if="showRadio" :checked="item.goods_state" color="#c00000" @click="radioChangeHandle"></radio>
			<image class="good-pic" :src="item.goods_small_logo" mode=""></image>
		</view>
		<!-- right -->
		<view class="good-item-right">
			<view class="good-name">{{item.goods_name}}</view>
			<view class="goods-info">
				<view class="good-price">￥ {{item.goods_price | toFixed}}</view>
				<!-- 商品数量 -->
				<uni-number-box 
				@change="change"
				:value="item.goods_count" :min="1" v-if="showNumber"/>
			</view>
			
		</view>
		
	</view>
</template>

<script>
	export default {
		name:"my-goods",
		props:{
			item:{
				type:Object,
				default:{}
			},
			showRadio:{
				type:Boolean,
				default:false
			},
			showNumber:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				
			};
		},
		filters:{
			toFixed(num){
				return Number(num).toFixed(2)
			}
		},
		methods:{
			radioChangeHandle(){
				this.$emit('radioChange',{
					goods_id:this.item.goods_id,
					goods_state:! this.item.goods_state
				})
			},
			change(value){
				this.$emit('numberChange',{
					goods_id:this.item.goods_id,
					goods_count : value
				})
			}
		}
	}
</script>

<style lang="scss">
	.good-item{
		display: flex;
		padding: 20rpx 10rpx;
		border-bottom:2rpx solid #f0f0f0;
		.good-item-left{
			margin-right: 10rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.good-pic{
				height: 200rpx;
				width: 200rpx;
				display: block;
			}
		}
	
		.good-item-right{
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			flex: 1;
			.good-name{
				font-size: 28rpx;
			}
			.goods-info{
				display: flex;
				justify-content: space-between;
				align-items: center;
			}
			.good-price{
				font-size: 36rpx;
				color: #c00000;
			}
			
		}
	}
</style>